﻿@namespace MudBlazor.UnitTests.TestComponents

<MudText>SelectedItems { @string.Join(", ", selectedItems) }</MudText>
<MudTable Items="Items"
          T="TableGroupingTest.RacingCar"
          MultiSelection="true"
          SelectOnRowClick="true"
          SelectionChangeable="false"
          @bind-SelectedItems="selectedItems"
          GroupBy="@groups"
          GroupHeaderStyle="background-color:var(--mud-palette-background-gray)"
          RowClass="row-click-test"
          OnRowClick="(args) => ++_count">
    <HeaderContent>
        <MudTh>Name</MudTh>
    </HeaderContent>
    <GroupHeaderTemplate>
        <MudTh>@($"{context.GroupName}: {context.Key}")</MudTh>
    </GroupHeaderTemplate>
    <RowTemplate>
        <MudTd>@context.Name</MudTd>
    </RowTemplate>
    <FooterContent>
        <MudTd>F</MudTd>
    </FooterContent>
</MudTable>
<MudText>Clicked: @_count</MudText>

@code {
    public static string __description__ = "The checkboxes should all be disabled on load, even the header, group headers and footer checkboxes.";
    public IEnumerable<TableGroupingTest.RacingCar> Items { get; private set; } = [
        new("F488", "Ferrari", "GTE"),
        new("919 Hybrid", "Porsche", "LMP1"),
        new("911 RSR", "Porsche", "GTE"),
        new("911 RS", "Porsche", "GT3")
    ];
    private TableGroupDefinition<TableGroupingTest.RacingCar> groups = new()
    {
        GroupName = "Category",
        Selector = rc => rc.Category,
        InnerGroup = new()
        {
            GroupName = "Brand",
            Selector = rc => rc.Brand
        }
    };
    private HashSet<TableGroupingTest.RacingCar> selectedItems = [];
    private int _count = 0;
}
